<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .el-header, .el-footer {
            background-color: #B3C0D1;
            color: #333;
            text-align: center;
            line-height: 60px;
        }

        .el-main {
            background-color: #E9EEF3;
            color: #333;
            text-align: center;
            line-height: 160px;

        }

        body > .el-container {
            margin-bottom: 40px;
        }

        .el-container:nth-child(5) .el-aside,
        .el-container:nth-child(6) .el-aside {
            line-height: 260px;
        }

        .el-container:nth-child(7) .el-aside {
            line-height: 320px;
        }
        .el-table__header tr,
        .el-table__header th {
            padding: 0;
            height: 30px;
            line-height: 30px;
        }
        .el-table__body tr,
        .el-table__body td {
            padding: 0;
            height: 30px;
            line-height: 30px;
        }
    </style>
</head>
<body>
<div id="my">
    <el-container>
        <el-header>
            <el-row>
                <el-col :span="4"><div class="grid-content bg-purple">

                </div></el-col>
                <el-col :span="12"><div class="grid-content bg-purple-light">
                    <template>
                        <el-select v-model="activeName.id" clearable placeholder="日期">
                            <el-option
                                    v-for="item in listDate"
                                    :key="item.id"
                                    :label="item.registrationdate"
                                    :value="item.id">
                            </el-option>
                        </el-select>
                    </template>
                    <el-button icon="el-icon-search" circle @click="searchDep"></el-button>
                </div></el-col>
                <el-col :span="8"><div class="grid-content bg-purple">

                </div></el-col>
            </el-row>
        </el-header>
        <el-main>
            <el-tabs v-model="activeName.nameList" type="border-card"  stretch  @tab-click="listOwn">
                <el-tab-pane label="挂号信息" name="first" >
                    <template>
                        <el-table
                                :data="oneTableData"
                                :header-cell-style="{textAlign:'center'}"
                                :cell-style="{textAlign:'center'}"
                                style="width: 100%">
                            <el-table-column
                                    prop="name"
                                    label="姓名"
                                    min-width="300">
                            </el-table-column>
                            <el-table-column
                                    prop="telephone"
                                    label="手机号"
                                    min-width="200">
                            </el-table-column>
                            <el-table-column
                                    prop="registrationdate"
                                    label="日期"
                                    min-width="300">
                            </el-table-column>
                            <el-table-column
                                    prop="day"
                                    label="时间"
                                    min-width="300">
                                <template slot-scope="scope">
                                    <span v-if="scope.row.day==0" style="margin-left: 10px">上午</span>
                                    <span v-if="scope.row.day==1" style="margin-left: 10px">下午</span>
                                </template>
                            </el-table-column>
                            <el-table-column
                                    label="操作"
                                    min-width="100">
                                <template slot-scope="scope">
                                    <el-button  type="text" size="small" @click="showUpdateRe(scope.row.sid,scope.row.uid,scope.row.dateid,scope.row.day)">处理</el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                    </template>
                </el-tab-pane>
                <el-tab-pane label="排班信息" name="second" >
                    <template>
                        <el-table
                                :data="twoTableData"
                                :header-cell-style="{textAlign:'center'}"
                                :cell-style="{textAlign:'center'}"
                                style="width: 100%">
                            <el-table-column
                                    prop="registrationdate"
                                    label="日期"
                                    min-width="300">
                            </el-table-column>
                            <el-table-column
                                    prop="price"
                                    label="价格"
                                    min-width="200">
                            </el-table-column>
                            <el-table-column
                                    prop="upname"
                                    label="上午剩余号码"
                                    min-width="300">
                            </el-table-column>
                            <el-table-column
                                    prop="downname"
                                    label="下午剩余号码"
                                    min-width="300">
                            </el-table-column>
                        </el-table>
                    </template>
                </el-tab-pane>
            </el-tabs>
        </el-main>
    </el-container>
    <div class="block">
        <span class="demonstration">总数</span>
        <el-pagination
                @current-change="handleCurrentChange"
                :page-size="7"
                layout="total, prev, pager, next"
                :total="sum">
        </el-pagination>
    </div>
    <el-dialog title="病历填写" :visible.sync="dialogFormVisible">
        <el-form :model="form" ref="form" :rules="rules">
            <el-form-item label="病理" prop="content">
                <el-input v-model="form.content" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="处理结果" prop="dealwith">
                <el-input v-model="form.dealwith" autocomplete="off"></el-input>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="dialogFormVisible = false">取 消</el-button>
            <el-button type="primary" @click="updateRegistration">确 定</el-button>
        </div>
    </el-dialog>

</div>
<script>
    $.get("/demo/doct/listdate",function (backData) {
        he.listDate=backData.data;
    })
    var he=new Vue({
        el:"#my",
        data:{
            listDate:[],
            activeName:{
                nameList:'first'
            },
            oneTableData: [],
            twoTableData:[],
            sum:'',
            dialogFormVisible:false,
            rules:{
                content: [
                    { required: true, message: '请填写', trigger: 'blur' },
                ],
                dealwith: [
                    { required: true, message: '请填写', trigger: 'blur' },
                ],
            },
            form:{},
            msg:'',
        },
        methods:{
            searchDep(){
                if(he.activeName.nameList=="second"){
                    getList(1,7);
                }else{
                    getRegistration(1,7)
                }
            },
            handleCurrentChange(val){
                if(he.activeName.nameList=="second"){
                    getList(val,7);
                }else {
                    getRegistration(val,7)
                }
            },
            listOwn(tab, event){
                if(he.activeName.nameList=="second"){
                    getList(1,7);
                }else{
                    getRegistration(1,7)
                }

            },
            showUpdateRe(sid,uid,dateid,day){
                he.dialogFormVisible=true;
                he.form.sid=sid;
                he.form.uid=uid;
                he.form.dateid=dateid;
                he.form.day=day;
            },
            updateRegistration(){
                $.post("/demo/doct/updateRe",he.form,function (backData) {
                    he.msg=backData.msg;
                    if(backData.code==1){
                        he.$message({
                            showClose: true,
                            message: '已处理',
                            type: 'success'
                        });
                        he.dialogFormVisible=false;
                        he.form={};
                        window.location.reload();
                        he.activeName.nameList="first";
                    }else{
                        he.$message({
                            showClose: true,
                            message: he.msg,
                            type: 'warning'
                        });
                    }
                })
            }
        }
    })
    function getList(a,b) {
        he.activeName.page=a;
        he.activeName.count=b;
        $.post("/demo/doct/listTwo",he.activeName,function (backData) {
            he.twoTableData=backData.data.doctorLists;
            he.sum=backData.data.twosum;
        })
    }
    function getRegistration(a,b){
        he.activeName.page=a;
        he.activeName.count=b;
        $.post("/demo/doct/listOne",he.activeName,function (backData) {
            he.oneTableData=backData.data.listall;
            he.sum=backdata.data.onesum;
        })
    };
    getList(1,7);
</script>
</body>
</html>